package aes.server;

import javax.swing.*;
import java.awt.*;
import java.util.*;

/**
 * This class represents AES server user interface
 *
 */
public class ServerUI extends JFrame implements Observer{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextArea textArea = null;
	
	/**
	 * Constructor
	 */
	public ServerUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle("AES Server");
		
		textArea = new JTextArea();
		textArea.setEditable(false);
		textArea.setForeground(Color.GREEN);
		textArea.setBackground(Color.BLACK);
		
		JScrollPane scrollPane = new JScrollPane(textArea);
		
		getContentPane().add(scrollPane, BorderLayout.CENTER);
		
		this.setSize(640, 480);
	}

	/**
	 * Handles massage from observable object in our case from Server class
	 */
	@Override
	public void update(Observable arg0, Object arg1) {
		// Update user interface
		textArea.setText(textArea.getText() + arg1.toString() + "\n");
	}

}
